package com.ai.controller.made.ai_api;


import com.ai.annotation.EnterPathParamLog;
import com.ai.common.CommonResponse;
import com.ai.entity.made.camera.CameraIdBO;
import com.ai.entity.made.camera.CameraSwitch;
import com.ai.entity.made.camera.ReceiveCameraInfoBx;
import com.ai.entity.network.L1ToIdentifySysMessage;
import com.ai.model.vo.BatchOperateCameraParam;
import com.ai.service.made.AlgorithmCameraService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 算法接口----摄像头开关算法
 * @author jiaok
 * @since 2023-04-03 21:17:12
 */
@RestController
@RequestMapping("/algorithmAPI/camera")
@Slf4j
public class CameraAPI {

    @Resource
    AlgorithmCameraService algorithmCameraService;


    @PostMapping("receiveCameraInfo")
    @ApiOperation("获取摄像头信息")
    @EnterPathParamLog
    public CommonResponse receiveCameraInfo(@RequestBody @Valid List<ReceiveCameraInfoBx> cameraInfoBxList) {
        // TODO: 2024-09-13 摄像头信息由宝信下发
        return algorithmCameraService.receiveCameraInfo(cameraInfoBxList);
    }

    @PostMapping("getCameraInfo")
    @ApiOperation("获取摄像头状态")
    @EnterPathParamLog
    public CommonResponse getCameraState(@RequestBody @Valid List<String> cameraCodeList) {
        // TODO: 2024-09-13 摄像头信息由宝信下发
        return algorithmCameraService.getCameraState(cameraCodeList);

    }

    @PostMapping("cameraSwitch")
    @ApiOperation("摄像头开关")
    @EnterPathParamLog
    public CommonResponse cameraSwitch(@RequestBody CameraSwitch cameraSwitch) {
        // TODO: 2024-09-13 摄像头信息由宝信下发
        return algorithmCameraService.cameraSwitch(cameraSwitch);
    }

    /**
     * 打开摄像头
     */
    @PostMapping("onOpen")
    @ApiOperation("打开摄像头")
    @EnterPathParamLog
    public CommonResponse onOpen(@RequestBody CameraIdBO cameraIdBO) {
        CommonResponse resultData = algorithmCameraService.onOpen(cameraIdBO);
        log.info(resultData.toString());
        return resultData;
    }

    @PostMapping("batchOpening")
    @ApiOperation("批量开启摄像头")
    @EnterPathParamLog
    public CommonResponse batchOpening(@RequestBody BatchOperateCameraParam batchOperateCameraParam) {
        CommonResponse resultData = algorithmCameraService.batchOpening(batchOperateCameraParam);
        return resultData;
    }



    /**
     * 关闭摄像头
     */
    @PostMapping("onClose")
    @ApiOperation("关闭摄像头")
    @EnterPathParamLog
    public CommonResponse onClose(@RequestBody CameraIdBO cameraIdBO) {
        CommonResponse resultData = algorithmCameraService.onClose(cameraIdBO);
        log.info(resultData.toString());
        return resultData;
    }

    /**
     * 检测启动
     */
    @PostMapping("detectionStart")
    @ApiOperation("检测启动")
    public CommonResponse detectionStart() {
        CommonResponse resultData = algorithmCameraService.detectionStart();
        log.info(resultData.toString());
        return resultData;
    }

}
